<!DOCTYPE html>

<html>
<head>
  <title>BareObject</title>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
  <link rel="stylesheet" media="all" href="docco.css" />
</head>
<body>
  <div id="container">
    <div id="background"></div>
    
      <ul id="jump_to">
        <li>
          <a class="large" href="javascript:void(0);">Jump To &hellip;</a>
          <a class="small" href="javascript:void(0);">+</a>
          <div id="jump_wrapper">
          <div id="jump_page">
            
              
              <a class="source" href="Array.coffee.html">
                Array.coffee.md
              </a>
            
              
              <a class="source" href="BareObject.coffee.html">
                BareObject.coffee.md
              </a>
            
              
              <a class="source" href="Boolean.coffee.html">
                Boolean.coffee.md
              </a>
            
              
              <a class="source" href="Function.coffee.html">
                Function.coffee.md
              </a>
            
              
              <a class="source" href="Math.coffee.html">
                Math.coffee.md
              </a>
            
              
              <a class="source" href="Maybe.coffee.html">
                Maybe.coffee.md
              </a>
            
              
              <a class="source" href="Nullable.coffee.html">
                Nullable.coffee.md
              </a>
            
              
              <a class="source" href="Number.coffee.html">
                Number.coffee.md
              </a>
            
              
              <a class="source" href="Object.coffee.html">
                Object.coffee.md
              </a>
            
              
              <a class="source" href="Promise.coffee.html">
                Promise.coffee.md
              </a>
            
              
              <a class="source" href="String.coffee.html">
                String.coffee.md
              </a>
            
              
              <a class="source" href="Type.coffee.html">
                Type.coffee.md
              </a>
            
              
              <a class="source" href="header.coffee.html">
                header.coffee.md
              </a>
            
          </div>
        </li>
      </ul>
    
    <ul class="sections">
        
        
        
        <li id="section-1">
            <div class="annotation">
              
              <div class="pilwrap ">
                <a class="pilcrow" href="#section-1">&#182;</a>
              </div>
              <h1 id="bareobject">BareObject</h1>

            </div>
            
            <div class="content"><div class='highlight'><pre>	
	Object.from = Function.From(Scalar,Value).Returning(<span class="hljs-function">-&gt;</span> <span class="hljs-keyword">new</span> Object) \
		<span class="hljs-function"><span class="hljs-params">(obj)</span> -&gt;</span> <span class="hljs-function"><span class="hljs-params">(key,value)</span> -&gt;</span> obj[key] = value
	
	Object.equal = Predicate.From(Object,Object) \
		<span class="hljs-function"><span class="hljs-params">(a,b)</span> -&gt;</span>
			Array.reduce(Boolean.<span class="hljs-keyword">and</span>) [
				( a[prop] == b[prop] <span class="hljs-keyword">for</span> own prop <span class="hljs-keyword">of</span> a )...,
				( a[prop] == b[prop] <span class="hljs-keyword">for</span> own prop <span class="hljs-keyword">of</span> b )...
			]
	
	Object.remove = Function.From([Scalar]) \
		<span class="hljs-function"><span class="hljs-params">(fields...)</span> -&gt;</span> Function.From(Object).Returning(<span class="hljs-function">-&gt;</span> <span class="hljs-keyword">new</span> Object) \
			<span class="hljs-function"><span class="hljs-params">(obj)</span> -&gt;</span> <span class="hljs-function"><span class="hljs-params">(source)</span> -&gt;</span>
				obj[key] = value <span class="hljs-keyword">for</span> own key, value <span class="hljs-keyword">of</span> source <span class="hljs-keyword">when</span> key <span class="hljs-keyword">not</span> <span class="hljs-keyword">in</span> fields
	
	Object.project = Function.From([Scalar]) \
		<span class="hljs-function"><span class="hljs-params">(fields...)</span> -&gt;</span> Function.From(Object).Returning(<span class="hljs-function">-&gt;</span> <span class="hljs-keyword">new</span> Object) \
			<span class="hljs-function"><span class="hljs-params">(obj)</span> -&gt;</span> <span class="hljs-function"><span class="hljs-params">(source)</span> -&gt;</span>
				obj[key] = value <span class="hljs-keyword">for</span> own key, value <span class="hljs-keyword">of</span> source <span class="hljs-keyword">when</span> key <span class="hljs-keyword">in</span> fields
	
	Object.rename = Function.From(Object) \
		<span class="hljs-function"><span class="hljs-params">(renaming)</span> -&gt;</span> Function.From(Object).Returning(<span class="hljs-function">-&gt;</span> <span class="hljs-keyword">new</span> Object) \
			<span class="hljs-function"><span class="hljs-params">(obj)</span> -&gt;</span> <span class="hljs-function"><span class="hljs-params">(source)</span> -&gt;</span>
				obj[ renaming[key] <span class="hljs-keyword">or</span> key ] = value <span class="hljs-keyword">for</span> own key, value <span class="hljs-keyword">of</span> source
	
	Object.union = Function.overload [
	
		Function.From(Array).Returning(<span class="hljs-function">-&gt;</span> <span class="hljs-keyword">new</span> Object) \
			<span class="hljs-function"><span class="hljs-params">(union)</span> -&gt;</span> <span class="hljs-function"><span class="hljs-params">(objects)</span> -&gt;</span>
				union[key] = value <span class="hljs-keyword">for</span> own key, value <span class="hljs-keyword">of</span> object <span class="hljs-keyword">for</span> object <span class="hljs-keyword">in</span> objects
			
		Function.From<span class="hljs-function"><span class="hljs-params">([Object])</span> <span class="hljs-params">(objects...)</span> -&gt;</span> Object.union objects
		
	]
	
	Object.intersection = Function.overload [
	
		Function.From(Array).Returning(<span class="hljs-function">-&gt;</span> <span class="hljs-keyword">new</span> Object) \
			<span class="hljs-function"><span class="hljs-params">(intersection)</span> -&gt;</span> <span class="hljs-function"><span class="hljs-params">([first,rest...])</span> -&gt;</span>
				intersection[key] = value <span class="hljs-keyword">for</span> own key, value <span class="hljs-keyword">of</span> first <span class="hljs-keyword">when</span> rest.all Object.has(key)
					
		Function.From<span class="hljs-function"><span class="hljs-params">([Object])</span> <span class="hljs-params">(objects...)</span> -&gt;</span> Object.intersection objects
			
	]
	
	Object.difference = Function.overload [
	
		Function.From(Array).Returning(<span class="hljs-function">-&gt;</span> <span class="hljs-keyword">new</span> Object) \
			<span class="hljs-function"><span class="hljs-params">(difference)</span> -&gt;</span> <span class="hljs-function"><span class="hljs-params">([first,rest...])</span> -&gt;</span>
				difference[key] = value <span class="hljs-keyword">for</span> own key, value <span class="hljs-keyword">of</span> first <span class="hljs-keyword">when</span> rest.none Object.has(key)
	
		Function.From<span class="hljs-function"><span class="hljs-params">([Object])</span> <span class="hljs-params">(objects...)</span> -&gt;</span> Object.difference objects
	
	]	
	
	Object.join = Function.From(Function) \
		<span class="hljs-function"><span class="hljs-params">(predicate)</span> -&gt;</span> Function.From([Object]) \
			<span class="hljs-function"><span class="hljs-params">(objects...)</span> -&gt;</span> Object.union objects... <span class="hljs-keyword">if</span> predicate objects...</pre></div></div>
            
        </li>
        
        
        <li id="section-2">
            <div class="annotation">
              
              <div class="pilwrap ">
                <a class="pilcrow" href="#section-2">&#182;</a>
              </div>
              <h1 id="object-with-defaults">Object with defaults</h1>

            </div>
            
            <div class="content"><div class='highlight'><pre>	
	Object.<span class="hljs-function"><span class="hljs-title">WithDefaults</span> = <span class="hljs-params">(defaults)</span> -&gt;</span> <span class="hljs-function"><span class="hljs-params">(object)</span> -&gt;</span> Object.union defaults, object</pre></div></div>
            
        </li>
        
    </ul>
  </div>
</body>
</html>
